<?php /*a:3:{s:43:"D:\myweb\lemocms\view\admin\auth\group.html";i:1569314347;s:46:"D:\myweb\lemocms\view\admin\common\header.html";i:1569314347;s:46:"D:\myweb\lemocms\view\admin\common\footer.html";i:1569314347;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo config('admin.sys_name'); ?>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/main.css?v=<?php echo time(); ?>" media="all">
    <link rel="stylesheet" href="/static/plugins/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style id="LM-bg-color">
    </style>
</head>
<div class="LM-container">
    <div class="LM-main">
        <div class="admin-main layui-anim layui-anim-upbit">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>权限组<?php echo lang('list'); ?></legend>
                <blockquote class="layui-elem-quote">
                    <div class="LM-table">
                        <form class="layui-form layui-form-pane">
                            <div class="layui-inline">
                                <input type="text" name="title" lay-verify="required" placeholder="<?php echo lang('pleaseEnter'); ?>添加" autocomplete="off" class="layui-input">
                            </div>
                            <button class="layui-btn data-add-btn layui-btn-sm" lay-submit="" lay-filter="add"><?php echo lang('add'); ?></button>

                        </form>

                    </div>

                  </blockquote>

            </fieldset>



            <table class="layui-table" id="list" lay-filter="list"></table>
        </div>
    </div>
</div>


<script type="text/html" id="action">
    <a href="<?php echo url('groupAccess'); ?>?id={{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal">配置规则</a>
    <a href="<?php echo url('groupEdit'); ?>?id={{d.id}}" class="layui-btn layui-btn-warm layui-btn-xs"><?php echo lang('edit'); ?></a>
    {{# if(d.id==1){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled"><?php echo lang('del'); ?></a>
    {{# }else{  }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><?php echo lang('del'); ?></a>
    {{# } }}
</script>
<script type="text/html" id="status">
    {{# if(d.id==1){ }}
    <input type="checkbox" disabled name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" checked>
    {{# }else{  }}
    <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
    {{# } }}
</script>
<script type="text/html" id="create_time">
    {{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script type="text/html" id="update_time">
    {{layui.util.toDateString(d.update_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script src="/static/plugins/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        var tableIn = table.render({
            elem: '#list',
            url: '<?php echo url("group"); ?>',
            method: 'post',
            cols: [[
                {checkbox: true, fixed: true},
                {field: 'id', title: 'ID', width: 80, fixed: true, sort: true},
                {field: 'title', title: '组名', width: 150, fixed: true,},
                {field: 'status', title: '状态', width: 180, templet:'#status'},
                {field: 'create_time', title: '添加时间', width: 180,templet:'#create_time'},
                {field: 'update_time', title: '修改时间', width: 180,templet:'#update_time'},
                {title:'操作',width:250, toolbar: '#action',align:"center"},

            ]],

        });
        // 监听添加操作
        form.on('submit(add)', function (data) {
            var result = data.field;
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("<?php echo url('groupAdd'); ?>", result, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 2000, icon: 1});
                    tableIn.reload();
                } else {
                    layer.msg(res.msg, {time: 2000, icon: 2});
                    return false;
                }

            });
            return false;
        })

        table.on('tool(list)', function(data){
            console.log(data);
            var obj = data.data;
            if(data.event === 'del'){
                layer.confirm('<?php echo lang("Are you sure you want to delete it"); ?>', function(index){
                    loading =layer.load(1, {shade: [0.1,'#fff']});
                    $.post("<?php echo url('groupDel'); ?>",{id:obj.id},function(res){
                        layer.close(loading);
                        layer.close(index);
                        if(res.code>0){
                            layer.msg(res.msg,{time:1000,icon:1});
                            data.del();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                });
            }


        });

        form.on('switch(status)', function(data){
                loading =layer.load(1, {shade: [0.1,'#fff']});
                $.post("<?php echo url('groupState'); ?>",{id:data.value},function(res){
                    layer.close(loading);
                    if(res.code>0){
                        layer.msg(res.msg,{time:1000,icon:1});
                    }else{
                        layer.msg(res.msg,{time:1000,icon:2});
                    }
                });
        });

    });


</script>